//
//  SEGMenuNavigationBarViewController.m
//  SEGShumYip
//
//  Created by 山刘 on 2019/11/18.
//  Copyright © 2019 山刘. All rights reserved.
//

#import "SEGMenuNavigationBarViewController.h"

@interface SEGMenuNavigationBarViewController ()
@end

@implementation SEGMenuNavigationBarViewController

/**
 用于展示默认的导航栏样式
 */
-(void)viewDidLoad{
    [super viewDidLoad];
    [self initSubViews];
}

-(void)initSubViews{
    self.view.backgroundColor = kColor_W;
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.navDisplayType = SEGNavigationBarDisplayTypeHide;
    
    [self.view addSubview:self.naviBarView];
    [self.view addSubview:self.tableView];
    
    self.tableView.delegate = self;
    self.tableView.bounces = NO;
    
    //25891 【深到家v1.1.0】iOS 我的页面，菜单数据展示不全（见截图）
    [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(self.naviBarView.layout.totalHeight);
        make.left.right.bottom.equalTo(self.view);
    }];
}
/**
 这里用于布局样式
 */
-(void)refreshOtherData{
    SEGMenuListModel *model = [SEGMenuListManager segGetNavigationBarData:self.menuDataSource];
    SEGMenuNaviViewModel *data = [[SEGMenuNaviViewModel alloc]init];
    data.menuData = model;
    SEGMenuNaviViewLayout *layout = [[SEGMenuNaviViewLayout alloc]initWithData:data type:[model.widgetType integerValue]];
    [self.naviBarView setWithLayout:layout];

    [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(self.naviBarView.layout.totalHeight);
        make.left.right.bottom.equalTo(self.view);
    }];
}

#pragma mark - getter
-(SEGMenuNaviView *)naviBarView{
    if (!_naviBarView) {
        SEGMenuNaviViewModel *data = [[SEGMenuNaviViewModel alloc]init];
        SEGMenuNaviViewLayout *layout = [[SEGMenuNaviViewLayout alloc]initWithData:data type:SEGEnumShowTypeNavigationBar_99003];
        _naviBarView = [[SEGMenuNaviView alloc]initWithFrame:CGRectZero];
        [_naviBarView setWithLayout:layout];
    }
    return _naviBarView;
}
@end
